package com.z001.snack.common.common.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.z001.snack.common.filter.NotReturnFilter;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * Entity 基础类
 *      1. 默认字段都不返回前端(NotReturnFilter),用于后端数据库查看
 *      2. 如业务需要用到创建人或创建时间等,请在数据库建字段,不使用默认字段当做业务字段
 * @author szy
 * @Date 2023/7/10 11:06
 */
@Data
public class BaseEntity {

    /**
     * 是否删除  10=>未删除  90=>已删除
     */
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotReturnFilter.class)
    @TableLogic(value = "10", delval = "90")
    @TableField(fill = FieldFill.INSERT)
    private Integer rowStatus;

    /**
     * 创建人id
     */
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotReturnFilter.class)
    @TableField(fill = FieldFill.INSERT)
    private Long createUser;

    /**
     * 创建人姓名
     */
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotReturnFilter.class)
    @TableField(fill = FieldFill.INSERT)
    private String createUserName;

    /**
     * 创建时间
     */
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotReturnFilter.class)
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 修改人id
     */
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotReturnFilter.class)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long  updateUser;

    /**
     * 修改人姓名
     */
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotReturnFilter.class)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateUserName;

    /**
     * 修改时间
     */
    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotReturnFilter.class)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
}
